package com.yeswater.rabbitmq;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.yeswater.rabbitmq.utils.RabbitmqUtil;

import java.nio.charset.StandardCharsets;

/**
 * 死信队列实战 生产者
 * Author : yeswater
 */

public class Producer {

    public static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitmqUtil.getChannel();

        AMQP.BasicProperties props = new AMQP.BasicProperties().builder().expiration("10000").build();

        for (int i = 0; i < 10; i++) {
            String message = "info" + (i+1);
            channel.basicPublish(NORMAL_EXCHANGE,"normal", props, message.getBytes(StandardCharsets.UTF_8));
            System.out.println(message);
        }
    }

}
